package com.zw.pm.module.integrate.daily;

import com.zw.pm.base.BaseController;
import com.zw.pm.common.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Description: 生产日报查询 控制层
 *
 * @Author: China.sgl
 * @Date: 2019/9/16 09:11
 */
@Slf4j
@Controller
@RequestMapping("/integrate/daily")
public class ProduceDailyController extends BaseController {

    @Autowired
    private ProduceDailyService produceDailyService;

    /**
     * 页面
     * 
     * @return 页面路径
     */
    @GetMapping
    @RequiresPermissions({"integrate:daily"})
    public String project(Model model) {
        model.addAttribute("factories", produceDailyService.findFactories());
        return "integrate/produceDaily/page";
    }

    /**
     * 列表
     * 
     * @param produceDailyModel 查询条件
     * @return list
     */
    @ResponseBody
    @PostMapping("/list")
    @RequiresPermissions({"integrate:daily"})
    public JsonResult list(ProduceDailyModel produceDailyModel) {
        long start = System.currentTimeMillis();
        startPage();
        List<ProduceDailyModel> list = produceDailyService.findProject(produceDailyModel);
        log.debug("生产日报列表查询用时（毫秒）" + (System.currentTimeMillis() - start));
        return jsonResult(list);
    }

}
